<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        p {
            height: 400px;
            border: solid;
        }
    </style>

</head>

<body>

    <p>p1</p>
    <p>p2</p>
    <p>p3</p>
    <p>p4</p>
    <p>p5</p>
    <p>p6</p>

    <script>
        // 窗口滚动事件
        window.onscroll = function () {
            // 计算窗口滚动是否触底
            console.log(document.documentElement.scrollHeight - window.pageYOffset - window.innerHeight);
        }

    </script>

</body>

</html>